package com.parkwalk.xxx.synch;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.parkwalk.xxx.util.Configurations;

/**
 * @author borball.zh@gmail.com
 * @date 2012-5-6
 * 
 */
public class SynchroniserImpl implements Synchroniser{

	Logger logger = LoggerFactory.getLogger(SynchroniserImpl.class);
	private String serverUrl = Configurations.getInstance().getProperty("server.service.url");
	
	@Override
	public Response getFromServer(Request request) {
		String url = generateHttpGetUrl(request);
		logger.info("Get from Server, url:" + url);
		//TODO: fetch content from server
		
		return null;
	}

	@Override
	public Response postToServer(Request request) {
		String url = generateHttpPostUrl(request);
		logger.info("Post to Server, url:" + url);
		//TODO: post content from server
		
		return null;
	}

	/**
	 * Security?
	 * @param request
	 * @return
	 */
	private String generateHttpGetUrl(Request request){
		return serverUrl + "/" + request.getType();
	}
	
	private String generateHttpPostUrl(Request request){
		return null;
	}
}
